package com.hehui.partimejob.fragment;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.hehui.partimejob.BaseActivity;
import com.hehui.partimejob.PartTimeDetailActivity;
import com.hehui.partimejob.R;
import com.hehui.partimejob.adapter.MyRecyclerViewAdapter;
import com.hehui.partimejob.service.model.PartTimeModel;
import com.hehui.partimejob.uitls.DisplayUtil;
import com.nex3z.flowlayout.FlowLayout;

import java.util.ArrayList;
import java.util.List;

public class VerifyFragment extends BaseFragment {

    private RecyclerView rv;

    private List<PartTimeModel> verifyList = new ArrayList<PartTimeModel>();
    private MyRecyclerViewAdapter<PartTimeModel> adapter;

    @Override
    public void init() {
        getNav().getNav().setBackgroundColor(A.getColor(R.color.white));
        getNav().setTitle(R.string.verify).setTitleColor(A.getColor(R.color.black)).isShowBack(false);
        rv = (RecyclerView) findViewById(R.id.rv);


        A.receiveMsg(new BaseActivity.AbstractOnMyReceiveListener<PartTimeModel>() {
            @Override
            public void onMessage(PartTimeModel t) {
                verifyList.add(0, t);
                adapter.notifyItemRangeInserted(0,1);
            }
        });
        rv.setAdapter(adapter = new MyRecyclerViewAdapter<PartTimeModel>(verifyList, R.layout.rv_part_time_item) {

            @Override
            protected void handleData(InnerHolder holder, PartTimeModel item) {
//                Glide.with(A).load(item.getImg()).into((ImageView) holder.getView(R.id.pic));
//                holder.setText(R.id.yuan, item.getPrice() + getString(R.string.yuan))
//                        .setText(R.id.title, getString(R.string.partTimeTitle) + item.getTitle())
//                        .setText(R.id.address, getString(R.string.partTimeAddress) + item.getAddress());
//                String labelStr = item.getLabel();
//                String[] split = labelStr.split("&");
//                FlowLayout flowLayout = holder.getView(R.id.labelFl);
//                for (String s : split) {
//                    TextView textView = new TextView(A);
//                    textView.setHeight(DisplayUtil.dp2px(A, 30));
//                    textView.setBackgroundResource(R.drawable.fl_layout_item_bg);
//                    textView.setGravity(Gravity.CENTER);
//                    textView.setTextColor(A.getColor(R.color.pri_red));
//                    textView.setPadding(DisplayUtil.dp2px(A, 16), DisplayUtil.dp2px(A, 3), DisplayUtil.dp2px(A, 16), DisplayUtil.dp2px(A, 3));
//                    textView.setText(s);
//                    flowLayout.setChildSpacing(DisplayUtil.dp2px(A, 8));
//                    flowLayout.addView(textView);
//                }
//
//
////                        事件
//                holder.getView(R.id.item).setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        A.startActivity(PartTimeDetailActivity.class);
//                    }
//                });
            }
        });


    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_verify;
    }

    @Override
    protected void begin(Bundle bundle) {

    }


}
